

//
//  FirstTableViewCell.m
//  GoShops
//
//  Created by zcj on 15-11-25.
//  Copyright (c) 2015年 郑朝军. All rights reserved.
//

#import "FirstTableViewCell.h"
#import "Grouble.h"
@interface FirstTableViewCell()
@property(nonatomic,weak)UIImageView * touxiang;
@property(nonatomic,weak)UILabel * nameTitles;

@end
@implementation FirstTableViewCell
+ (instancetype)FirstTableViewCell:(UITableView *)tableView
{
    static NSString *menuID = @"mefirstcell";
    FirstTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:menuID];
    if (cell == nil) {
        cell = [[FirstTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:menuID];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        UIView * bakView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 120)];
        bakView.backgroundColor = [UIColor whiteColor];
        [self addSubview:bakView];
        
        CGFloat margen = 20;
        
        CGFloat touxiangX = margen;
        CGFloat touxiangY = margen;
        
        // 头像
        UIImageView * touxiang = [[UIImageView alloc]init];
        touxiang.contentMode = UIViewContentModeLeft;
        [touxiang setImage:[UIImage imageNamed:@"icon_mine_default_portraits"]];
        touxiang.frame = CGRectZero;
        
        CGRect touxiangRect = CGRectMake(touxiangX, touxiangY, touxiang.image.size.width, touxiang.image.size.height);
        
        touxiang.frame = touxiangRect;
        
        [bakView addSubview:touxiang];
        self.touxiang = touxiang;
        
        // 名称
        
        CGFloat nameTitleX = CGRectGetMaxX(touxiangRect) + margen;
        CGFloat nameTitleY = touxiangY + 10;
        NSString * nameTitle = @"郑朝军";
        CGFloat nameTitleW = ScreenWidth - nameTitleX - margen;
        CGSize nameSize = [nameTitle sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20]}];
        UILabel * nameTitles = [[UILabel alloc]initWithFrame:CGRectMake(nameTitleX, nameTitleY, nameTitleW, nameSize.height)];
        nameTitles.numberOfLines = 0;
        nameTitles.text = nameTitle;
        nameTitles.font = [UIFont systemFontOfSize:18];
        nameTitles.textAlignment = NSTextAlignmentLeft;
        nameTitles.textColor = [UIColor blackColor];
        [bakView addSubview:nameTitles];
        self.nameTitles = nameTitles;
        
        NSArray * btnName = @[@"晒单",@"已购买",@"未完成"];
        
        CGFloat meituanW = ScreenWidth / 3;
        CGFloat meituanH = 40;
        CGFloat meituanY = 80;
        
        // 
        for (int i = 0; i < 3; i ++) {
            CGFloat meituanX = meituanW * i;
            
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            //btn.titleLabel.text = btnName[i];
            [btn setTitle:btnName[i] forState:UIControlStateNormal];
            
            ZCJLog(@"%@",btnName[i]);
            btn.tag = 100 + i;
            
            [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            
            btn.titleLabel.font = [UIFont systemFontOfSize:15];
            btn.backgroundColor = ZCJColor(70, 71, 83);
            btn.frame = CGRectMake(meituanX, meituanY, meituanW, meituanH);
            [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
            [bakView addSubview:btn];
        }
        // Initialization code
    }
    return self;
}
- (void)btnClick:(UIButton *)btn
{
    ZCJLog(@"通知控制器%d",btn.tag);
}
- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
